package com.aixingfu.sports.MVP.presenter;

import android.util.Log;

import com.aixingfu.sports.Https.NetHome;
import com.aixingfu.sports.Https.NetListener;
import com.aixingfu.sports.MVP.contract.LoginContract;
import com.aixingfu.sports.MVP.contract.RetrievePwdContract;
import com.aixingfu.sports.Model.CodeModel;
import com.aixingfu.sports.Model.LoginModel;
import com.aixingfu.sports.Model.RetrievePwdModel;

import java.util.HashMap;

/**
 * Author : 吕冬冬
 * Time : 2019.05.08 0011
 * Description :
 */
public class RetrievePwdPresenter implements RetrievePwdContract.MyPresenter {

    RetrievePwdContract.MyView mView;
    @Override
    public void attachView(RetrievePwdContract.MyView view) {
        mView=view;
    }

    @Override
    public void detachView() {
        this.mView = null;
    }

    @Override
    public boolean isViewAttached() {
        return mView != null;
    }

    public void getCode(HashMap<String,String> map){
        mView.showLoading();
        NetHome.loadData(NetHome.getApi(mView.getMyContext()).getCode(map), new NetListener<CodeModel>() {
            @Override
            public void onSuccess(CodeModel data) {
                mView.setCode(data);
            }

            @Override
            public void onFailed(int errCode, String errMsg) {
                Log.i("打印数据", "onFailed: "+errCode+"  "+errMsg);
            }

            @Override
            public void onComplete() {
                mView.hideLoading();
            }
        });

    }
    public void getRetrievePwd(HashMap<String,String> map){
        mView.showLoading();
        NetHome.loadData(NetHome.getApi(mView.getMyContext()).getRetrievePassword(map), new NetListener<RetrievePwdModel>() {
            @Override
            public void onSuccess(RetrievePwdModel data) {
                mView.setRetievePwd(data);
            }

            @Override
            public void onFailed(int errCode, String errMsg) {
                Log.i("打印数据", "onFailed: "+errCode+"  "+errMsg);
            }

            @Override
            public void onComplete() {
                mView.hideLoading();
            }
        });

    }
}
